/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JOrderLinkPanel.java
 *
 * Created on 2010-1-30, 14:12:11
 */

package cn.ekuma.epos.qkorder.link;

import cn.ekuma.data.ui.swing.JChildDAOEditorPanel;
import cn.ekuma.epos.datalogic.I_DataLogicCustomers;
import cn.ekuma.epos.datalogic.I_DataLogicERP;
import cn.ekuma.epos.datalogic.I_DataLogicSystem;
import cn.ekuma.epos.order.JOrderRelationEditor;
import cn.ekuma.epos.order.model.OrderRelationTableModel;
import cn.ekuma.epos.qkorder.event.OrderChangedEvent;
import cn.ekuma.epos.qkorder.event.OrderChangedListener;
import com.openbravo.bean.erp.Order;
import com.openbravo.bean.erp.OrderRelation;
import com.openbravo.data.user.DirtyManager;
import com.openbravo.pos.base.AppView;


/**
 * 
 * @author Administrator
 */
@SuppressWarnings("serial")
public class JOrderLinkPanel extends JChildDAOEditorPanel<OrderRelation> implements OrderChangedListener {
	private Order order;

	/** Creates new form JOrderLinkPanel */
	public JOrderLinkPanel(AppView app,I_DataLogicERP dlSales,I_DataLogicSystem dlSystem,I_DataLogicCustomers dlCustomers) {
		super(null,new OrderRelationTableModel(),new JOrderRelationEditor(app,new DirtyManager(), dlSales, dlSystem, dlCustomers));
	}

	@Override
	public void orderChanged(OrderChangedEvent e) {
		order = e.getOrder();
		updateUI(e.isEditAble());
		tableModel.resert(order.getRefOrders());
	}

	@Override
	public void addObject() {
		super.addObject();
		if (editorDialog.getRetObj() != null){
			OrderRelation newObj=(OrderRelation) editorDialog.getRetObj();
			newObj.setSuperID(order.getId());
		}
	}
}
